﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;

namespace Nexxo.Channel.DMS.Web.Models
{
    /// <summary>
    /// Something about what the <c>MySomeFunction</c> does
    /// with some of the sample like
    /// <code>
    /// Some more code statement to comment it better
    /// </code>
    /// For more information seee <see cref="http://www.me.com"/>
    /// </summary>
    /// <param name="someObj">What the input to the function is</param>
    /// <returns>What it returns</returns>
    public class PersonalInformation
    {
        public PersonalInformation()
        {
            InitializeDropDowns();
        }

        [Display(Name = "First Name ")]
        [RegularExpression(@"^[a-zA-Z\- ']*$", ErrorMessage = "Please Enter only Alphabet, Hyphen, Apostrophe or Spaces in First Name.")]
        [StringLength(20, ErrorMessage = "Maximum Length Of First Name is 20")]
        [Required(ErrorMessage = "Please Enter First Name.")]
        public string FirstName { get; set; }

        [Display(Name = "Middle Name")]
        [RegularExpression(@"^[a-zA-Z\- ']*$", ErrorMessage = "Please Enter only Alphabet, Hyphen, Apostrophe or Spaces in Middle Name.")]
        [StringLength(20, ErrorMessage = "Maximum Length Of Middle Name is 20")]
        public string MiddleName { get; set; }

        [Display(Name = "Last Name ")]
        [RegularExpression(@"^[a-zA-Z\- ']*$", ErrorMessage = "Please Enter only Alphabet, Hyphen, Apostrophe or Spaces in Last Name.")]
        [StringLength(30, ErrorMessage = "Maximum Length Of Last Name is 30")]
        [Required(ErrorMessage = "Please Enter Last Name.")]
        public string LastName { get; set; }

        [Required(ErrorMessage = "Please Select Gender.")]
        [Display(Name = "Gender ")]
        public string Gender { get; set; }

        [Display(Name = "Primary Phone ")]
        [RegularExpression(@"^[2-9](\d)(?!\1{8}$)\d*$", ErrorMessage = "Please Enter a valid Phone Number.")]
        [Required(ErrorMessage = "Please Enter Phone Number.")]
        [StringLength(10, MinimumLength = 10, ErrorMessage = "Phone Number should be 10 digits in length.")]
        public string PrimaryPhone { get; set; }

        [Display(Name = "Primary Phone Type")]
        [Required(ErrorMessage = "Please Select Phone Type.")]
        [Default("Select", "PrimaryPhoneType",true, ErrorMessage = "Please Select Phone Type.")]
        public string PrimaryPhoneType { get; set; }

        [Display(Name = "Primary Phone Provider")]
        [Required(ErrorMessage = "Please Select Phone Provider.")]
        [Default("Select", "PrimaryPhoneProvider", true, "PrimaryPhoneType", "Cell", ErrorMessage = "Please Select Phone Provider.")]
        public string PrimaryPhoneProvider { get; set; }

        [Display(Name = "Alternative Phone")]
        [RegularExpression(@"^[2-9](\d)(?!\1{8}$)\d*$", ErrorMessage = "Please Enter a valid Phone Number.")]
        [StringLength(10, MinimumLength = 10, ErrorMessage = "Phone Number should be 10 digits in length.")]
        public string AlternativePhone { get; set; }

        [Display(Name = "Alternative Phone Type")]
        [Default("Select", "AlternativePhoneType",false, ErrorMessage = "Please Select Phone Type.")]
        public string AlternativePhoneType { get; set; }

        [Display(Name = "Alternative Phone Provider")]
        [Default("Select", "AlternativePhoneProvider",false, "AlternativePhoneProvider", "Cell", ErrorMessage = "Please Select Phone Provider.")]
        public string AlternativePhoneProvider { get; set; }

        [Display(Name = "Email")]
        [RegularExpression(@"^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$", ErrorMessage = "Please Enter a valid Email format.")]
        [StringLength(200, ErrorMessage = "Maximum length of email is 200")]
        public string Email { get; set; }

        [Display(Name = "Address1 ")]
        [RegularExpression(@"^(?!.*(P|p)\.? ?(O|o)\.? ?(Box|bOx|boX|BOX|BOx|box))[-a-zA-Z\d .,/]*$", ErrorMessage = "Please enter a valid street address (no PO boxes).")]
        [Required(ErrorMessage = "Please Enter Address")]
        public string Address1 { get; set; }

        [Display(Name = "Address2")]
        [RegularExpression(@"^(?!.*(P|p)\.? ?(O|o)\.? ?(Box|bOx|boX|BOX|BOx|box))[-a-zA-Z\d .,/]*$", ErrorMessage = "Please enter a valid street address (no PO boxes).")]
        public string Address2 { get; set; }

        [Display(Name = "City ")]
        [RegularExpression(@"^[a-zA-Z ]*$", ErrorMessage = "Special chars are not allowed in City.")]
        [StringLength(50, ErrorMessage = "Maximum length of City is 50")]
        [Required(ErrorMessage = "Please Enter City.")]
        public string City { get; set; }

        [Display(Name = "State ")]
        [Required(ErrorMessage = "Please Select  State.")]
        [Default("Select","State", true, ErrorMessage = "Please Select  State.")]
        public string State { get; set; }

        [Display(Name = "Zip Code ")]
        [RegularExpression(@"^\d{5}$", ErrorMessage = "Please Enter a valid Zip Code.")]
        [Required(ErrorMessage = "Please Enter Zip Code.")]
        public string ZipCode { get; set; }

        [Display(Name = "Referral Number")]
        [RegularExpression(@"^[0-9]{8}$", ErrorMessage = "Please enter a valid 8 digit Referral code.")]
        public string ReferralNumber { get; set; }

        [Display(Name = "Receive Text Message")]
        public bool ReceiveTextMessage { get; set; }

        [Display(Name = "WoodForest Account Holder")]
        public bool WoodForestAccountHolder { get; set; }

        [Display(Name = "Second Last Name")]
        [RegularExpression(@"^[a-zA-Z\- ' ]*$", ErrorMessage = "Please Enter only Alphabet, Hyphen, Apostrophe or Spaces in Second Last Name.")]
        [StringLength(30, ErrorMessage = "Maximum Length Of Second Last Name is 30")]
        public string SecondLastName { get; set; }

        [Display(Name = "Do Not Call")]
        public bool DoNotCall { get; set; }

        //[Display(Name = "Country ")]
        //[Required(ErrorMessage = "Please select Country Name.")]
        //public string Country { get; set; }

        public IEnumerable<SelectListItem> PPhonetype { get; set; }
        public IEnumerable<SelectListItem> PPhoneProvider { get; set; }
        public IEnumerable<SelectListItem> LGender { get; set; }
        public IEnumerable<SelectListItem> LStates { get; set; }
        public IEnumerable<SelectListItem> LCountries { get; set; }

        public void InitializeDropDowns()
        {
            PPhonetype = Nexxo.Channel.DMS.Web.Controllers.PersonalInformationController.PhoneType();
            PPhoneProvider = Nexxo.Channel.DMS.Web.Controllers.PersonalInformationController.PhoneProvider();
            LGender = Nexxo.Channel.DMS.Web.Controllers.PersonalInformationController.Gender();
            LStates = Nexxo.Channel.DMS.Web.Controllers.PersonalInformationController.USStates();
            LCountries = Nexxo.Channel.DMS.Web.Controllers.PersonalInformationController.Country();

        }
    }
}